<?php

require './site/dkp/dkpfunctions.php';

if (isEditable())
{
	if (isset($_POST['removeRaiders']))
		removeRaiders();
	if (isset($_POST['activateRaiders']))
		activateRaiders();
	if (isset($_POST['addName']))
		addRaider();
	if (isset($_POST['editName']))
		editRaider();
}
showPageHeader();
showIntroText();
	if (isEditable())
	{
		if (isset($_GET['action']) && $_GET['action'] == 'update')
		{
			if (isset($_GET['edit']))
			{
				displayRaiderInput(getRaiderInfo($_GET['edit']));
			} else {
				displayRaiderInput('add');
			}
		}
	}
showDetail();
showPageFoot();



// -------------------------------------------------------------
//  ----  Functions  -----------------------------------------
// -------------------------------------------------------------
function showPageHeader()
/*
Opens the pages middle section content box and adds the title
*/
{
?>
    	<div id="content">
			<?php showDKPTitlebar('DKP Raiders - Beta'); ?>
            <div class="box">
                <div class="contents">
<?php
}
// -------------------------------------------------------------
function showPageFoot()
/*
Displays final links and closes the pages middle section content box
*/
{
?>
                </div>
				<p style="text-align: right;">
					<?php manageLink(); ?>
				</p>
            </div>
			<?php 
				if (isEditable() && isset($_GET['action']) && $_GET['action'] == 'update')
					displayDKPLog(20); 
			?>
    	</div>
<?php
}
// -------------------------------------------------------------
function manageLink()
/*
Displays the update page link for those authorised to use it
*/
{
	if (isEditable())
	{
		if (isset($_GET['action']) && $_GET['action'] == 'update')
		{
			echo '<a href="index.php?page=dkpraiders">Exit update page</a><br />';
		} else {
			echo '<a href="index.php?page=dkpraiders&action=update">Update page</a><br />';
		}
	}
}
// -------------------------------------------------------------
function showIntroText()
/*
Displays the text at the top of the page
*/
{
?>
					<p style="padding: 5px 10px 10px 4px;">
						Below are the DMZ raiders.
					</p>
<?php
}
// -------------------------------------------------------------
function showDetail()
/*
Displays the main page content
*/
{
	if (isEditable() && isset($_GET['action']) && $_GET['action'] == 'update')
	{
		echo '<p style="font-weight: bold">Manage raiders:</p>';
	}
	$raidersArray = getRaidersArray();
	displayChart($raidersArray);
	$addedRaiders = array(0);
	$signupArray = array(0);
	displayActiveRaiders($raidersArray, $addedRaiders, $signupArray);
	displayNonactiveRaiders($raidersArray);
//	print_r($raidersArray);
}
// -------------------------------------------------------------
// -------------------------------------------------------------
?>
